import { defineStore } from 'pinia'
import { storage } from '../utils'
// const currentUser = storage.get('CURRENT_USER', {})
export default defineStore('base', {
  state: () => ({
    accessToken: '',
  }),
  actions: {
    loadState() {
      const currentToken = storage.get('CURRENT_TOKEN', null);
      this.$patch({ accessToken: currentToken });
    },
    setAllState(newState: String) {
      console.log('setAllState')
      storage.set('CURRENT_TOKEN', newState);
      const newStateAsString: string = String(newState);
      this.$patch({ accessToken: newStateAsString });
    },
    getAllState(): String {
      this.loadState();
      return this.accessToken;
    },
  }
})
